import React, { useEffect } from 'react';
import { Table } from 'antd';
import { connect } from 'react-redux';
import action from '@/store/action/index.js';
import { Radio, Button } from 'antd';
const column = [
    {
        title: '保单号',
        dataIndex: 'policyNo',
        key: 'policyNo',
    },
    {
        title: '批单号',
        dataIndex: 'orderNumber',
        key: 'orderNumber',
    },
    {
        title: '保单类型',
        dataIndex: 'policyType',
        key: 'policyType',
    },
    {
        title: '日期',
        dataIndex: 'applicationDate',
        key: 'applicationDate',
    },
];
const ReduxDom = (props) => {
    const { tableList, getTableData, getKeepOrderList, getTabs, tabList, tabActive, setTabActive, changeRowApplicationDate } = props
    useEffect(() => {
        if (!tabList.length) {
            getTabs()
        }
        if (!tableList.length) {
            getKeepOrderList(tabActive)
        }
    }, []);
    const columns = [...column, {
        title: 'Action',
        key: 'action',
        render: (_, record) => (
            <Button type="primary" onClick={() => changeRowApplicationDate(record.preserveId)}>改变日期</Button>
        ),
    },]
    return (
        <div>
            <Radio.Group value={tabActive} buttonStyle="solid" onChange={e => {
                setTabActive(e.target.value)
                getTableData()
            }}>
                {
                    tabList.map(item => {
                        return <Radio.Button value={item} key={item}>{item}</Radio.Button>
                    })
                }
            </Radio.Group>
            <Table columns={columns} dataSource={tableList} rowKey="preserveId" size="small" />;
        </div>
    );
}

export default connect((state) => state.keepIntactOrder, action.keepIntactOrderAction)(ReduxDom);
